<!--
 * @Author: ChunLai
 * @Date: 2023-03-17 11:58:04
 * @LastEditTime: 2025-09-02 18:21:56
 * @Description: 必读pdf文件
 * @FilePath: \02.bldinsure\src\views\sign\components\protocols\MustReadPdf.vue
-->
<template>
  <div class="must_read_md">
    <div
      v-for="(item, index) in lists"
      class="protocol"
      :key="`pdf-must-${index}`"
      @click="openPdfPop(item)"
    >
      <div class="notice_img">
        <MsImgIcon size="13" name="checked" v-if="item.isFinish" />
      </div>
      <div class="clause_ul">
        <i>本人已阅读并同意</i> <em>{{ getFileName(item.fileName) }}</em>
      </div>
    </div>

    <PdfReader
      ref="mustReadRef"
      btype="pop"
      :clickMode="clickMode"
      @toClick="closePopFile"
      v-if="showFile"
    />
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import PdfReader from '@/components/PdfReader';
export default {
  name: 'MustReadPdf',
  data() {
    return {
      showFile: false,
    };
  },
  components: { PdfReader },
  computed: {
    ...mapGetters({
      clickReadMode: "page/clickReadMode",
      lists: 'readings/pdfMustReadLists',
    }),
    clickMode() {
      let res = "1";
      if (this.clickReadMode) {
        res = this.clickReadMode;
      }
      return res;
    },
  },
  created() {},
  mounted() {},
  methods: {
    getFileName(name) {
      let res = name;
      if (name && name.indexOf('《') == -1) {
        res = `《${name}》`;
      }
      return res;
    },
    openPdfPop(item) {
      this.showFile = true;
      this.$nextTick(() => {
        this.$refs.mustReadRef.initModule(item.fileUrl, item.fileName);
      });
    },
    closePopFile(pdfUrl) {
      this.$store.dispatch('readings/setItemPdfFinish', pdfUrl);
      this.showFile = false;
    },
  },
};
</script>

<style lang="less" scoped>
@import './style.less';
</style>
